package com.kg.fiber.service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.ivan.toolkit.network.JsonUDP;

@Component
public class Translayer extends JsonUDP {
	
	@Autowired
	private NodeBoss boss;
	
	@PostConstruct
	private void postConstruct() {
		this.start();
	}
	
	@PreDestroy
	private void preDestroy() {
		this.stop();
	}
	
	@Override
	public int getListenPort() {
		return 12345;
	}

	@Override
	public int getBufferSize() {
		return 8096;
	}

	@Override
	public void dispatch(String host, int port, JSONObject value) {
		boss.dispatch(host, port, value);
	}


}
